﻿using d1Common.Interface;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Principal;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
using System.Web.Http.Routing;

namespace d1Common.WebController
{
    public class ServiceTypeAttribute : AuthorizeAttribute
    { 

        public ServiceTypeAttribute()
        {

        }
        public string Id
        {
            get;
            set;
        }
        protected override bool IsAuthorized(System.Web.Http.Controllers.HttpActionContext actionContext)
        {
            if (this.Id == null || this.Id.Length <= 0) return true;
            string _serviceType = doServices.Instance.DoConfig.readLocalConfig("ServiceType", "");
            if (_serviceType == null || _serviceType.Length <= 0) return true;
            if (this.Id == _serviceType) return true;
            throw new UserException("不具调用服务类型：" + this.Id);
        }
    }
}